package com.yunheone.control;

import com.yunheone.mode.StudentUse;
import com.yunheone.view.Student.StudentAdd;
import com.yunheone.view.Student.StudentDell;
import com.yunheone.view.Student.StudentUI;

import java.util.HashMap;
import java.util.Map;

/**
 * Created by Administrator on 2017/8/9 0009.
 */
public class Studentcontrol {

    private static Map<String,StudentUse> studentmap = new HashMap<> (  );



//    跳转
    public static void studentRount(){
        int i= StudentUI.stedentUse ();
        switch (i){
            case 1:studentAdd ();break;
            case 2:studentRomve ();break;
            case 3:Teachercontrol.getInstance ().Rount ();break;
        }

    }

//   添加学员
    public static void studentAdd(){
        StudentUse studentUse = StudentAdd.studentUse ();
        if (studentUse !=null) {
            studentmap.put (studentUse.getId (), studentUse );
        }
        studentRount ();
        System.out.println ("添加成功！");
    }

//    删除学员
    public static void studentRomve(){
        StudentUse studentUse = StudentDell.studentDell ();
        if (!studentmap.get ( studentUse.getId () ).getGrade ().equals ( studentUse.getGrade () )){
            if (!studentmap.containsKey ( studentUse.getId () )){
                System.out.println ("查无此人！");
                studentRount ();
            }
        }
        studentmap.remove ( studentUse.getId () );
        studentRount ();
        System.out.println ("删除成功");
    }

    public static Map<String, StudentUse> getStudentmap() {
        return studentmap;
    }
}

